package com.lovo.user.controller;

import com.lovo.common.bean.User;
import com.lovo.common.result.ResponseResult;
import com.lovo.common.util.MQUtil;
import com.lovo.user.form.UserForm;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@ResponseResult
@RequestMapping("/mq")
@Tag(name = "测试消息发送")
public class MQController {
    @Autowired
    private MQUtil mqUtil;
    @GetMapping("/send")
    public Object send(String exchangeName,String routerKey,String message){
        mqUtil.send(exchangeName,routerKey,message);
        return null;
    }
    @PostMapping("/sendObj")
    public Object sendObj(String exchangeName, String routerKey,@RequestBody UserForm userForm){
        User user = new User();
        BeanUtils.copyProperties(userForm,user);
        mqUtil.send(exchangeName,routerKey,user);
        return null;
    }
}
